package com.example.mybank.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mybank.entity.engine;

import com.example.mybank.mapper.EngineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class EngineConfig {

//    @Autowired
    engine engineDefault;

    @Autowired
    EngineMapper engineMapper;


    @Bean("engineDefault")
    public engine engineDefault(EngineMapper engineMapper){
        QueryWrapper<engine> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("is_default",Boolean.TRUE);
        List<engine> engines = engineMapper.selectList(queryWrapper);
        if(engines.size()!=0) {
            return engines.get(0);
        }else{
            engineDefault =new engine(
                    0L,
                    "默认引擎",
                    Boolean.TRUE,
                    0L,
                    Boolean.TRUE,
                    Boolean.TRUE,
                    Boolean.TRUE,
                    Boolean.TRUE,
                    Boolean.TRUE,
                    3L,
                    2L,
                    3L,
                    10000L,
                    5000L,
                    18L
                    );
            engineMapper.insert(engineDefault);
            return engineDefault;
        }

//            description: "默认引擎"
//            is_use: true
//            count: 0
//            is_default: true
//            delay_need: true
//            work_need: true
//            honest_need: true
//            age_need: true
//            delay_year: 3
//            delay_count: 2
//            delay_return_days: 3
//            delay_money_min: 1000
//            delay_money_sum: 10000
//            delay_money_max: 5000
//            age_min: 18
    }


}
